package com.yoso.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yoso.dao.UserMapper;
import com.yoso.domain.UserEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.support.TransactionTemplate;

import javax.annotation.Resource;

/**
 * @author shizejin
 * @date 2022/8/1
 * @description:
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper,UserEntity> implements UserService{
    @Resource
    private TransactionTemplate transactionTemplate;

    @Override
    public void test1() {
        UserEntity san = new UserEntity();
        san.setUsername("test1");
        this.save(san);
        test2("test2");
    }

    @Override
    public void test2(String arg) {
        UserEntity san = new UserEntity();
        san.setUsername(arg);
        transactionTemplate.execute(status -> this.save(san));
        this.save(san);
        int i = 1/0;
    }
}
